import org.gradle.api.DefaultTask
import org.gradle.api.tasks.TaskAction

/**
 * Author: Sergey Saiyan
 * Created: 19.07.13 23:22 
 */
class SetupTomcat extends DefaultTask {

    def tomcatRootDir = project.tomcatDir

    SetupTomcat() {
        setDescription('Sets up local Tomcat')
        setGroup('Development server')
    }

    @TaskAction
    def setup() {
        project.configurations.tomcat.files.each { dep ->
            project.copy {
                from project.zipTree(dep.absolutePath)
                into tomcatRootDir
            }
        }
        ant.chmod(osfamily: 'unix', perm: 'a+x') {
            fileset(dir: "${tomcatRootDir}/bin", includes: '*.sh')
        }
    }
}
